import axios from 'axios'
import { url, getToken, setToken } from './index'
import { Toast } from 'vant'
const request = axios.create({
    baseURL: url
})
request.interceptors.request.use(config => {

    if (config.url.startsWith('/user')) {
        config.headers.authorization = getToken()
    }
    console.log(config);

    return config
})
request.interceptors.response.use(res => {
    if (res.data.status === 400) {
        Toast('登录已过期，请重新登录')
        setToken('')
    }
    return res
})
export default request 